//package com.wigang.flowable;
//
//import okhttp3.*;
//import org.springframework.stereotype.Service;
//
//@Service
//public class ChatGPTRestClient {
//
//    private final OkHttpClient client;
//
//    public ChatGPTRestClient() {
//        this.client = new OkHttpClient();
//    }
//
//    /**
//     * Sends a message to the ChatGPT service.
//     *
//     * @param prompt The user input text sent as part of the request body.
//     */
//    public String sendMessage(String prompt){
//        RequestBody requestBody = new MultipartBody.Builder()
//                .setType(MultipartBody.FORM)
//                .addFormDataPart("prompt", prompt)
//                .build();
//
//        Request request = new Request.Builder()
//                .url("https://api.openai.com/v1/engines/davinci-codex/completions") // Replace with actual endpoint URL
//                .post(requestBody)
//                .header("Authorization", "Bearer YOUR_API_KEY_HERE")
//                .build();
//
//        try (Response response = client.newCall(request).execute()) {
//            if (!response.isSuccessful()){
//                throw new RuntimeException("Failed : HTTP error code : "
//                        + response.code());
//            }
//
//            return Objects.requireNonNull(response.body()).string();
//        } catch (IOException e) {
//            System.out.println(e.getMessage());
//            return null;
//        }
//    }
//}
